package domain.businessService.cardinfo;

import java.sql.SQLException;

import domain.businessEntity.cardinfo.CardInfo;
import foundation.data.DataContext;
import foundation.data.IDataContext;

public class CardService implements ICardService {

	//调试用字符串
	private static String Tag="CardinfoService";
	
	//声明了一个ctx变量
	private IDataContext ctx;
	
	//构造函数
	public CardService(){
		ctx=new DataContext();		
		
	}
	
	@Override
	public CardInfo getCardInfo(int cardID){
		CardInfo cardinfo=null;
		//构造块的创建
		try {
			cardinfo=ctx.queryById(CardInfo.class, Integer.class,cardID);
		} catch (SQLException e) {
			// TODO 自动生成的 catch 块
			e.printStackTrace();
		}
		return cardinfo;
	}
	@Override
	public void saveMyCardInfo(CardInfo mycard){
		try {
			ctx.add(mycard, CardInfo.class, Integer.class);
		} catch (SQLException e) {
			// TODO 自动生成的 catch 块
			e.printStackTrace();
		}
	}

	@Override
	public void updateMyCardInfo(CardInfo mycard) {
		// TODO Auto-generated method stub
		try {
			ctx.update(mycard, CardInfo.class, Integer.class);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
